package com.njwb.service.impl;

import com.njwb.mapper.DeptMapper;
import com.njwb.pojo.Dept;
import com.njwb.pojo.Emp;
import com.njwb.remote.service.FeignRemoteEmpService;
import com.njwb.service.DeptService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DeptServiceImpl  implements DeptService {
    @Autowired
    private FeignRemoteEmpService feignRemoteEmpService;
    @Autowired
    private DeptMapper deptMapper;
    @GlobalTransactional
    @Override
    public void add(Dept dept) {
        deptMapper.insert(dept);
        Emp emp = new Emp();
        emp.setEmpNo(7000 + dept.getDeptNo());
        emp.setEname("James");
        emp.setDeptNo(dept.getDeptNo());
        feignRemoteEmpService.add(emp);
    }
}
